require "event_editor/gadgets/switch_list_dialog"
require "gadgets/box_button"

module EventEditor
  module Gadgets
    class SwitchButton < ::Gadgets::BoxButton
      attr_reader :value
      def initialize(base, values, &func)
        @values = values
 
        f = Proc.new do
              SwitchListDialog.show(base, @values) do |arr, value|
                unless arr == :cancel
                  @values = arr
                  self.value = value
                  
                  func.call(arr)
                end
              end
            end
        super(&f)
        self.value = 0
      end
      
      def value=(no)
        @value = no
        self.text = "#{no}: " + @values[no]
      end
      
      def self.icon
        return @@icon
      end
    end
  end
end